﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

#endregion


namespace ESF.General.Text
{
	[AttributeUsage (AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] 
	public class ColumnAttribute : Attribute, IComparable <ColumnAttribute>
	{
		#region Propiedades

		public int ColumnOrder { set; get; }

		public int? MaxLength { set; get; }

		public int? MinLength { set; get; }

		public string RegularExpression { set; get; }

		public string Name { set; get; }

		public string DateFormat { set; get; }

		public bool IsBool { set; get; }

		public bool IsInt { set; get; }

		public bool IsPK { set; get; }

		public PropertyInfo SeteableProperty;

		#endregion


		#region Constructor

		public ColumnAttribute (int pColumnOrder) : this (pColumnOrder, string.Empty)
		{
			
		}


		public ColumnAttribute (int pColumnOrder, string pName)
		{
			ColumnOrder = pColumnOrder;
			Name = pName;
		}

		#endregion

		public int CompareTo(ColumnAttribute pOther)
		{
			if (pOther == null) { return 0; }

			return pOther.ColumnOrder.CompareTo (pOther.ColumnOrder);
		}
	}
}
